from os.path import join, dirname
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget, QApplication, QLabel

class MyWidget(QWidget):
    def __init__(self):
        super(MyWidget, self).__init__()
        self.setWindowTitle("使用QLabel显示图片示例1")
        self.resize(800, 600)
        self.label = QLabel(self)
        self.label.setGeometry(0, 0, 300, 200)
        img_file = join(dirname(__file__), "res", "test.jpg")
        self.label.setPixmap(QPixmap(img_file))

app = QApplication([])
w = MyWidget()
w.show()
app.exec_()
